<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="client" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{clientHome.managed ? 'Edit' : 'Add'} Client</f:facet>



            <s:decorate id="loginField" template="layout/edit.xhtml">
                <ui:define name="label">Login</ui:define>
                <h:inputText id="login"
                           size="45"
                      maxlength="45"
                          value="#{clientHome.instance.login}">
                    <a:support event="onblur" reRender="loginField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{clientHome.persist}"
                       disabled="#{!clientHome.wired}"
                       rendered="#{!clientHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{clientHome.update}"
                       rendered="#{clientHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{clientHome.remove}"
                      immediate="true"
                       rendered="#{clientHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Client.xhtml"
                rendered="#{clientHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty clientFrom ? 'ClientList' : clientFrom}.xhtml"
                rendered="#{!clientHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Reservations">
        <h:form styleClass="association" id="reservationsChildren">

            <h:outputText value="There are no reservations associated with this client."
                       rendered="#{empty clientHome.reservations}"/>

            <rich:dataTable value="#{clientHome.reservations}"
                           var="_reservation"
                      rendered="#{not empty clientHome.reservations}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="reservationsTable">
                <rich:column sortBy="#{_reservation.idreservation}">
                    <f:facet name="header">Idreservation</f:facet>
                    <h:outputText value="#{_reservation.idreservation}"/>
                </rich:column>
                <rich:column sortBy="#{_reservation.dateReservation}">
                    <f:facet name="header">Date reservation</f:facet>
                    <h:outputText value="#{_reservation.dateReservation}">
                        <s:convertDateTime type="both" dateStyle="short"/>
                    </h:outputText>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{clientHome.managed}" id="reservations">
        <div class="actionButtons">
            <s:button id="addreservation"
                   value="Add reservation"
                    view="/ReservationEdit.xhtml"
             propagation="none">
                 <f:param name="clientIdclient"
                         value="#{clientHome.instance.idclient}"/>
                 <f:param name="reservationFrom" value="Client"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
